<template>
  <div class="likebox">
    <div class="likebox-wrap">
      <ul>
        <li class="likebox-item" v-for="(item) in goodList" :key="item.good_id">
          <div @click="goitem(item.good_id)">
            <div class="like-pic">
              <a>
                <img :src="item.src.slice(1, 71)" />
              </a>
            </div>
            <div class="like-info">
              <div class="info-wrap">
                <p class="info-name">{{ item.message }}</p>
                <p class="info-sub">{{ item.name }}</p>
              </div>
              <div class="like-price">
                <strong>￥{{item.price}}</strong>
                {{item.size}}
                <i></i>
              </div>
            </div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
// 引用indexgoodApi接口
import indexgoodApi from "@/api/indexgoodApi";
export default {
  data() {
    return {
      page: 1,
      pagesize: 6,
      goodList: []
    };
  },

  components: {},

  methods: {
    goitem(good_id) {
      console.log(good_id);
      this.$router.push("/details?" + good_id);
    }
  },
  created() {
    indexgoodApi
      .grtGoog02(this.page, this.pagesize)
      .then(res => {
        res.data;
        // console.log(res.data.data);
        this.goodList = res.data.data;
        // console.log(this.goodList);
      })
      .catch(err => {
        console.log(err);
      });
    // console.log(indexgoodApi.getGood());
  }
};
</script>

<style scoped>
.likebox {
  background: #fafafa;
}
.likebox-wrap {
  padding: 0 0.135rem;
}
.likebox-item > div {
  position: relative;
  padding: 0.1rem 0.085rem;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
  border-radius: 0.1rem;
  background: #fff;
  margin-bottom: 0.08rem;
}
.like-pic {
  float: left;
  width: 0.8rem;
  height: 0.8rem;
  line-height: 0.8rem;
  position: relative;
  margin-right: 0.12rem;
}
.like-pic > a > img {
  width: 0.8rem;
  height: 0.8rem;
}
.like-info {
  position: relative;
  height: 0.8rem;
}
.info-name {
  color: #000;
  font-size: 0.12px;
  line-height: 0.136rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  text-align: left;
}
.info-sub {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #8d8a8a;
  font-size: 0.12px;
  margin-top: 0.07rem;
  text-align: left;
}
.like-price {
  width: 1.8rem;
  height: 0.2rem;
  line-height: 0.2rem;
  padding-right: 0.05rem;
  position: absolute;
  bottom: 0;
  right: 0;
  font-size: 11px;
  color: #8d8a8a;
  text-align: left;
}
.like-price > strong {
  font-size: 12px;
  color: #fb3d3d;
  margin-right: 0.025rem;
}
.like-price > i {
  width: 0.22rem;
  height: 0.22rem;
  background: url("../../assets/img/indexcart.png") no-repeat;
  background-size: 100% 100%;
  background-color: #01b27a;
  position: absolute;
  bottom: 0;
  border-radius: 50%;
  right: 5px;
}
</style>